home *** CD-ROM | disk | FTP | other *** search
- From: Tony_Bateman@msn.com (Tony Bateman)
- Subject: Default Class Initialisation Question...
- Date: 24 Mar 96 19:36:28 -0800
- Message-ID: <00001a81+0000af6f@msn.com>
- Path: news.msn.com!msn.com
- Newsgroups: comp.lang.c++
- Organization: The Microsoft Network (msn.com)
-
- I have a problem concerning default initialisation of classes.
-
- If I define a class Rectangle, and have default initialisation values
- in the constructor defined thus:
-
- Rectangle::Rectangle(USHORT width=0, USHORT height=0):
- itsWidth(width),
- itsHeight(height)
- {}
-
- then I can define a rectangle to have a width = 30 and height = 0 by
- omitting one of the variables in the initialisation:
-
- Rectangle myRectangle(30);
-
- Fine. But what if I want to leave the width a default value of 0 and
- set the height to 30. How could I do it? Can it be done in C++ in a
- straightforward manner? Is there anything like a default placeholder
- that can be used?
-
- Regards,
- Tony Bateman.
-
- -----------------------------------------------------------------------------
- I live in Finland - second highest suicide rate per head of
- population in the world.
- It's the beginning of spring - most common time for suicides.
- Computer programmering is a recognised high risk suicide profession.
- Do NOT spill my pint.....
- -----------------------------------------------------------------------------
-
-